package com.itmentu.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author：http://www.itmentu.com
 * @date： 2021/12/6 10:49
 * @Description：
 ***/
@RestController
@RequestMapping(value = "/producer")
public class MessageProducer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 消息发送
     */
    @GetMapping(value = "/send")
    public String send(String message){
        /***
         * 消息发送
         * 路由的key是itmentu.topic
         * 发送的消息是message
         */
        rabbitTemplate.convertAndSend("topic_exchange","itmentu.topic",message);
        return "SUCCESS";
    }
}
